home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / fido / Rock_1_5.lha / ROCK / rock.rexx < prev    next >
OS/2 REXX Batch file  |  1995-05-12  |  4KB  |  203 lines

  1. /*
  2.              Rock v1.5 - Fidonet mailer for point systems
  3.  
  4.   This file is modified from jaz.f, Copyright (c) 1994 Robert Williamson
  5.        Modifications for Rock are Copyright (C) 1995  Jean-Marc Xiume'
  6.          This software is distributed under the terms of the
  7.     GNU General Public License. Read "license.doc" for more details.
  8.  
  9. ********************** Outbound scanner for XferQ **********************
  10. */
  11.  
  12. LF='A'x
  13. CR='D'x
  14.  
  15. qout=1
  16.  
  17. options results
  18. options failat 99
  19.  
  20. Parse upper arg od ha ra .
  21.  
  22. call random(,,time(s))
  23.  
  24. OBJ=XfqGetAddress(ra)
  25. if XfqSessionUp(OBJ) then do
  26.   if ~XfqHoldMailer(OBJ) then do
  27.     drop XFQERRORCODE XFQERRORMSG
  28.     v=XfqDropObject(OBJ)
  29.     v=XfqClose()
  30.     exit
  31.   end
  32. end
  33. else do
  34.   Say 'Site 'ra' not online, exiting rock.rexx'
  35.   drop XFQERRORCODE XFQERRORMSG
  36.   v=XfqDropObject(OBJ)
  37.   v=XfqClose()
  38.   return 1
  39. end
  40.  
  41. id=pragma('ID')
  42. xpr.H=0
  43. xpr.C=50
  44. xpr.D=30
  45. xpr.N=0
  46. xpr.F=0
  47. xpr.O=0
  48.  
  49. parse var ra rd "#" rz ":" rn "/" rf "." rp .
  50. v=sflos()
  51. v=souts()
  52.  
  53. cleanup:
  54. v=XfqReleaseMailer(OBJ)
  55. v=XfqDropObject(OBJ)
  56. v=XfqClose()
  57. v=delete('T:f'id)
  58. v=delete('T:o'id)
  59. exit 0
  60.  
  61.  
  62. sFLOS:
  63. Address COMMAND 'LIST >T:f'id od||rz'.'rn'.'rf'.'rp'.?LO quick nohead'
  64. if word(statef("T:f"id),2)=0 then return 0
  65. if ~open('fl',"T:f"id,'R') then return 0
  66. i=0
  67.  
  68. do while ~eof('fl')
  69.   L=Upper(strip(space(ReadLn('fl'),1),'B'))
  70.   if L="" then iterate
  71.   i=i+1
  72.   ff.i=L
  73.   parse var L fln.i.zone"."fln.i.net"."fln.i.node"."fln.i.point"."junk
  74.   ft=left(junk,1)
  75.   if pos(ft,'H C D N F')>0 then ff.i.pr=xpr.ft
  76.   else Iterate
  77. end
  78.  
  79. v=close('fl')
  80. if i=0 then return 0
  81. ff.nn=i
  82. do an=1 until an=ff.nn
  83.   err=0
  84.   fnm=upper(od||ff.an)
  85.   if ~exists(fnm) then err=1
  86.   else if ~Open('ff',fnm,'R') then err=1
  87.  
  88.   if ~err then do
  89.     say 'Scanning 'fnm
  90.     do while ~eof('ff')
  91.  
  92.       L=""
  93.       C=readch('ff',1)
  94.       do while (C~=CR & C~=LF & ~eof('ff'))
  95.     L=L||C
  96.     C=readch('ff',1)
  97.       end
  98.       if L="" then iterate
  99.       L=upper(L)
  100.  
  101.       flg=20
  102.       dp=left(L,1)
  103.       if dp="#" then do
  104.     flg=22
  105.     L=delstr(L,1,1)
  106.       end
  107.       else if dp="^"|dp="-" then do
  108.     flg=21
  109.     L=delstr(L,1,1)
  110.       end
  111.       else if dp="@" then do
  112.     flg=20
  113.     L=delstr(L,1,1)
  114.       end
  115.       if index(L,":")=0 then L=od||L
  116.       if ~exists(L) then do
  117.     say 'Cannot find 'L
  118.     iterate
  119.       end
  120.  
  121.       parse var L x '.' x '.' x '.' x '.' ex
  122.       drop x
  123.       if ex="" then do
  124.     if right(L,3)="TIC" then flg=21
  125.     as=gfn(L)
  126.     p=ff.an.pr
  127.       end
  128.       else do
  129.     tx=upper(left(ex,2))
  130.     if datatype(right(ex,1),'n')&(tx="MO"|tx="TU"|tx="WE"|tx="TH"|tx="FR"|tx="SA"|tx="SU") then do
  131.       /* parse var ha hd "#" hz ":" hn "/" hf "." hp
  132.          as=UPPER(d2x(65536+hn-fln.an.net,4)||d2x(65536+hf-fln.an.node,4)||'.'ex) */
  133.       as=right(compress(time(),":"),4)||d2x(random(0,255)+256*random(0,255),4)||'.'ex
  134.       flg=21
  135.       p=ff.an.pr
  136.     end
  137.     else do
  138.       as=gfn(L)
  139.       flg=20
  140.       p=ff.an.pr
  141.     end
  142.       end
  143.       drop ex
  144.  
  145.       QUERY.XQ_NAME=L
  146.       QUERY.XQ_SITE=OBJ
  147.       wn=NULL
  148.       wn=XfqFindWork(QUERY)
  149.       if wn=NULL then do
  150.     say 'Sending:'L' ['as'] :'ra' Disp:'flg' Pri:'p
  151.     v=XfqAddWorkQuick(ra,L,as,p,flg)
  152.       end
  153.       else v=XfqUnlockWork(wn)
  154.  
  155.     end
  156.     v=close('ff')
  157.   end
  158.  
  159.   if wn~=NULL then v=XfqDropObject(wn)
  160. end
  161. return 0
  162.  
  163.  
  164. sOUTS:
  165.  
  166. Address COMMAND 'LIST >T:o'id od||rz'.'rn'.'rf'.'rp'.?UT quick nohead'
  167. if word(statef("T:o"id),2)=0 then return 0
  168. if ~open('o',"T:o"id,'R') then return 0
  169.  
  170. do while ~eof('o')
  171.   of=upper(readln('o'))
  172.   if of="" then iterate
  173.  
  174.   parse var of x '.' x '.' x '.' x '.' ex
  175.   drop x
  176.   if ~qout & ex="OUT" then Iterate
  177.   xt=left(ex,1)
  178.   if pos(xt,'H C D N O')>0 then p=xpr.xt
  179.   else Iterate
  180.   file=od||of
  181.   as=left(date(),2)||compress(time(),":")||".PKT"
  182.   flg=21
  183.   QUERY.XQ_NAME=file
  184.   QUERY.XQ_SITE=OBJ
  185.   wn=NULL
  186.   wn=XfqFindWork(QUERY)
  187.   if wn=NULL then do
  188.     say 'Sending:'file' ['as'] :'ra' Disp:'flg' Pri:'p
  189.     v=XfqAddWorkQuick(ra,file,as,p,flg)
  190.   end
  191.   else v=XfqUnlockWork(wn)
  192.   if wn~=NULL then v=XfqDropObject(wn)
  193. end
  194. v=close('o')
  195. return 0
  196.  
  197.  
  198. gfn: procedure
  199.  
  200. if LastPos('/',arg(1))~=0 then return SubStr(arg(1),LastPos('/',arg(1))+1)
  201. else if LastPos(':',arg(1))~=0 then return SubStr(arg(1),LastPos(':',arg(1))+1)
  202. else return arg(1)
  203.